package com.ddd.interfaces.vo.user;

import com.ddd.infrastructure.utils.NullUtils;
import lombok.Data;

import java.io.Serializable;
@Data
public class UserVo implements Serializable {
    private static final long serialVersionUID = 1L;

    protected String userId; //用户的编号
    protected String name;
    protected Integer age;
    private String type;


    // 传输到页面前需要对数据进行处理  比如:状态的转换, 数据的显示转换......计算的规则

    public String getType() {  //生成新字段
        if (NullUtils.notEmpty(this.age)) {
            if (this.age < 18) {
                this.type = "儿童";
            } else if (this.age <= 30) {
                this.type = "青年";
            } else if (this.age <= 60) {
                this.type = "中年";
            } else {
                this.type = "老年";
            }
        } else {
            this.type = "未知";
        }

        return type;
    }
}
